package com.czd.support.service;

import com.czd.base.model.Paginate;
import com.czd.base.service.BaseService;
import com.czd.support.common.Configuration;
import com.czd.support.model.Answers;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Author: Jerry.hu
 * Create: Jerry.hu (2014-10-03 12:28)
 * Description:
 * To change this template use File | Settings | File Templates.
 */
@Service
public class AnswerService extends BaseService<Answers> {

    public Paginate queryForPaginate(Answers answers){
        answers.setPageSize(Configuration.getInstance().getDefault_page_size());
        return this.queryForPaginate(sqlId("queryForPaginate"),sqlId("answerCount"),answers);
    }

    public boolean insert(Answers answers){
        if(this.insertAndReturnId(sqlId("insert"),answers) > 0){
            return true;
        }
        else{
            return false;
        }
    }

    public Answers findById(int id) {
        return this.selectOne(sqlId("findById"),id);
    }

    public List<Answers> queryAnswersByQId(int qId){
        return this.selectList(sqlId("queryAnswersByQId"),qId);
    }


    public List<Answers> autocompleteById(int id) {
        return this.selectList(sqlId("queryForListById"),id);
    }

    public List<Answers> autocompleteByName(String content) {
        return this.selectList(sqlId("queryForListByContent"),content);
    }
}
